{% extends "base_generic.html" %}
{% block script %}
<script type="text/javascript">
  function generateUrl(name) {
    var sanitizedName = string_to_slug(name);
    $("#url").val(sanitizedName);
  }

  $(window).load(
    function() {
      imageUploader('logoFile', '{{filekey}}', 'addLogo');
    });

  function addLogo(key) {}

</script>
{% endblock %}
{% block content %}
        <h1>Marcas</h1>
        {% if logo %}
        <form method="post" action="/admin/brands/{{ filekey }}/edit/">
        {% else %}
        <form method="post" action="/admin/brands/{{ brand.key }}/save/">
        {% endif %}
          <div class="line">
            <div class="field">
              <label>Id:</label>
              <input type="text" id="brandId" name="brandId" value="{{ brandId }}" size="1" />
            </div>
            <div class="field">
              <label>Nombre:</label>
              <input type="text" id="name" name="name" value="{{ name }}" />
            </div>
            <div class="field">
              <label>URL:</label>
              <input type="text" id="url" name="url" value="{{ url }}" />
            </div>
            <div class="field">
              <label>Img:</label>
              {% if logo %}
              <img src="/image/{{ logo }}/30/auto/resized/" width="30" class="imgmain" />
              {% endif %}
              <div id="logoFile"></div>
            </div>
            <div class="field">
              <input type="submit" value="Añadir" id="save" name="save" />
              <input type="hidden" name="codenum" id="codenum" value="{{ filekey }}" />
            </div>
          </div>

        </form>
        <table class="imgswithoutborders">
          {% for brand in brands %}
          <tr>
             <td><img src="/image/{{ brand.imagekey }}/30/auto/resized/" width="30" /></td>
             <td>{{ brand.brandId }}</td>
             <td>{{ brand.name }}</td>
             <td>{{ brand.url }}</td>
             <td>{{ brand.productsCounter }} productos</td>
             <td><a href="/admin/brands/{{ brand.key }}/edit/">Editar</a></td>
             <td><a href="/admin/brands/{{ brand.key }}/delete/">Borrar</a></td>
          </tr>
          {% endfor %}
          <!-- tr>
           <td><img src="http://bgchhalepono.files.wordpress.com/2009/09/adidas_logo.jpg" width="30" /></td>
           <td>Adidas</td>
           <td>adidas</td>
           <td>3 productos</td>
           <td><a href="#">Editar</a></td>
            <td><a href="#">Borrar</a></td>
          </tr>
          <tr class="nolink">
            <td><img src="http://www.patuxentfa.org/imgs/Puma_Logo%283%29.gif" width="30"></td>
             <td>Puma</td>
             <td>puma</td>
             <td>7 productos</td>
             <td><a href="#">Editar</a></td>
              <td><a href="#">Borrar</a></td>
            </tr>
          <tr class="nolink">
            <td><img src="http://www.expertfootball.com/equipment/boots/reebok-logo.gif" width="30"></td>
           <td>Reebok</td>
           <td>reebok</td>
           <td>2 productos</td>
           <td><a href="#">Editar</a></td>
            <td><a href="#">Borrar</a></td>
          </tr -->
        </table>
{% endblock %}